﻿'Public Class DataListMenu
'    Inherits System.Web.UI.Page

'    Protected mDtPermissoes As DataTable

'    Protected Sub EncheMenu()
'        Try
'            Me.BuscaPermissoesUsuarioNoPortal()
'            Me.EncheDtlMenu()
'            Me.MostraPrimeiroPerfil()
'        Catch ex As Exception
'            Throw ex
'        End Try
'    End Sub

'    Protected Sub MostraPrimeiroPerfil()
'        If Me.dtlPerfils.Items.Count > 0 Then
'            Dim dtlTpForms As DataList = Me.dtlPerfils.Items(0).FindControl("dtlTpForms")
'            Dim dtlFormularios As DataList = dtlTpForms.Items(0).FindControl("dtlFormularios")

'            dtlTpForms.Visible = True
'            dtlFormularios.Visible = True
'        End If
'    End Sub

'    Private Sub BuscaPermissoesUsuarioNoPortal()
'        Dim obj As New ORMAdminDLL.clsORMTipoPerfilUsuarios()
'        Try
'            Dim PerfilNomePortalPermissao As String = "SaudeFOZ"
'            mDtPermissoes = obj.BuscaPermissoesUsuarioNoPortal(764, PerfilNomePortalPermissao)
'        Finally
'            obj.Dispose()
'            obj = Nothing
'        End Try
'    End Sub

'    Private Sub EncheDtlMenu()
'        Dim dt As New DataTable()
'        dt.Columns.Add(New DataColumn("TipoPerfilId", GetType(Integer)))
'        dt.Columns.Add(New DataColumn("TipPerfNome", GetType(String)))

'        Dim Aux As Integer = 0
'        For Each dtRow As DataRow In Me.mDtPermissoes.Rows()
'            If CInt(dtRow("TipoPerfilId")) <> Aux Then
'                Dim nrow As DataRow = dt.NewRow()
'                nrow("TipoPerfilId") = CInt(dtRow("TipoPerfilId"))
'                nrow("TipPerfNome") = dtRow("TipPerfNome")
'                dt.Rows.Add(nrow)
'                Aux = CInt(dtRow("TipoPerfilId"))
'            End If
'        Next
'        Me.dtlPerfils.DataSource = dt
'        Me.dtlPerfils.DataBind()
'    End Sub

'    Private Sub EncheDtlTpForms(ByVal DtlTpForms As DataList, ByVal _TipoPerfilId As Integer)
'        Dim dt As New DataTable()
'        dt.Columns.Add(New DataColumn("FormTipo", GetType(String)))

'        Dim Aux As String = ""
'        For Each dtRow As DataRow In Me.mDtPermissoes.Select("TipoPerfilId = " & _TipoPerfilId)
'            If dtRow("FormTipo") <> Aux Then
'                Dim nrow As DataRow = dt.NewRow()
'                nrow("FormTipo") = dtRow("FormTipo")
'                dt.Rows.Add(nrow)
'                Aux = dtRow("FormTipo")
'            End If
'        Next
'        DtlTpForms.DataSource = dt
'        DtlTpForms.DataBind()
'    End Sub

'    Private Sub EncheDtlFormularios(ByVal DtlTpForms As DataList, ByVal _TipoPerfilId As Integer)
'        For Each ditem As DataListItem In DtlTpForms.Items
'            Dim dtlFormularios As DataList = ditem.FindControl("dtlFormularios")
'            Dim lblFormTipo As LinkButton = ditem.FindControl("lblFormTipo")

'            Dim dt As New DataTable()
'            dt.Columns.Add(New DataColumn("TipoPerfilId", GetType(Integer)))
'            dt.Columns.Add(New DataColumn("FormularioID", GetType(Integer)))
'            dt.Columns.Add(New DataColumn("FormTipo", GetType(String)))
'            dt.Columns.Add(New DataColumn("FormNmMenu", GetType(String)))
'            dt.Columns.Add(New DataColumn("PageEndereco", GetType(String)))

'            Dim Aux As Integer = 0
'            For Each dtRow As DataRow In Me.mDtPermissoes.Select("TipoPerfilId = " & _TipoPerfilId & _
'                                                                " AND FormTipo = '" & lblFormTipo.Text & "'")
'                If CInt(dtRow("FormularioID")) <> Aux Then
'                    Dim nrow As DataRow = dt.NewRow()
'                    nrow("TipoPerfilId") = CInt(dtRow("TipoPerfilId"))
'                    nrow("FormularioID") = CInt(dtRow("FormularioID"))
'                    nrow("FormTipo") = dtRow("FormTipo")
'                    nrow("FormNmMenu") = dtRow("FormNmMenu")
'                    nrow("PageEndereco") = dtRow("PageEndereco")
'                    dt.Rows.Add(nrow)
'                    Aux = CInt(dtRow("FormularioID"))
'                End If
'            Next
'            dtlFormularios.DataSource = dt
'            dtlFormularios.DataBind()
'        Next
'    End Sub

'    Private Sub dtlPerfils_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dtlPerfils.ItemCommand
'        Try
'            If e.CommandName = "Mostrar" Then
'                For Each ditem As DataListItem In dtlPerfils.Items
'                    Dim _dtlTpForms As DataList = ditem.FindControl("dtlTpForms")
'                    _dtlTpForms.Visible = False

'                    For Each ditema As DataListItem In _dtlTpForms.Items
'                        Dim _dtlFormularios As DataList = ditema.FindControl("dtlFormularios")
'                        _dtlFormularios.Visible = False
'                    Next

'                Next
'                Dim dtlTpForms As DataList = e.Item.FindControl("dtlTpForms")
'                dtlTpForms.Visible = Not dtlTpForms.Visible
'            End If
'        Catch ex As Exception
'            Throw ex
'        End Try
'    End Sub

'    Private Sub dtlPerfils_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles dtlPerfils.ItemDataBound
'        Try
'            If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then
'                Dim lblTipoPerfilId As Label = e.Item.FindControl("lblTipoPerfilId")
'                Dim dtlTpForms As DataList = e.Item.FindControl("dtlTpForms")
'                Me.EncheDtlTpForms(dtlTpForms, lblTipoPerfilId.Text)
'                Me.EncheDtlFormularios(dtlTpForms, lblTipoPerfilId.Text)
'            End If
'        Catch ex As Exception
'            Throw ex
'        End Try
'    End Sub

'    Protected Sub lblFormTipo_Click(ByVal sender As Object, ByVal e As EventArgs)
'        Dim dtlTpForms As DataList = sender.parent.parent 'Pega o dtlTpForms anterior
'        For Each ditem As DataListItem In dtlTpForms.Items
'            Dim _dtlFormularios As DataList = ditem.FindControl("dtlFormularios")
'            _dtlFormularios.Visible = False
'        Next
'        Dim dtlFormularios As DataList = sender.parent.FindControl("dtlFormularios") 'Pega o dtlFormularios do Item clicado do dtlTpForms
'        dtlFormularios.Visible = Not dtlFormularios.Visible
'    End Sub

'    Protected Sub uia_Click(ByVal sender As Object, ByVal e As EventArgs) Handles uia.Click
'        Me.EncheMenu()
'    End Sub

'    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

'    End Sub
'End Class